import fileUpload from "@/components/file-upload.vue"
// import {TypeOptions} from "./constant"
import {getOptions} from "@/apis/order/index"
import store from "@/store/index"
import { getDateDetail } from "@/util/date"
export default async (that)=>{
	getOptions().then(res=>{
		console.log(res)
		store.commit("option/setBillOption",res.data)
	})
	return {
		columns:[
			{
				key:"expand",
				props:{
					type:"expand"
				},
				slot:"expand"
			},
			{
				key:"bid",
				slot:"bid",
				label:"账单编号",
				width:350,
				props:{
					"show-overflow-tooltip":true
				}
			},
			{
				key:"orderNo",
				label:"订单号",
				width:350,
			},
			{
				key:"money",
				label:"每单结算金额",
				width:120,
			},
			{
				key:"nickname",
				label:"微信昵称",
				// width:200,
			},
			{
				key:"phone",
				label:"手机尾号",
				// width:200,
			},
			{
				key:"amount",
				label:"实付金额",
				// width:200,
			},
			{
				key:"orderCreateTime",
				label:"订单创建时间",
				width:120,
			},
			// {
			// 	key:"createTime",
			// 	label:"创建时间",
			// 	width:200,
			// },
			// {
			// 	key:"updateTime",
			// 	label:"修改时间",
			// 	width:200,
			// },
			{
				key:"operation",
				label:"操作",
				slot:"operation",
				width:150,
				props:{
					fixed:"right"
				},
				removeBtn:{
					show:true,
					permission:"order:delete"
				},
				editBtn:{
					show:true,
					permission:"order:edit"
				},
			}
		],
		reqOptions:{
			list:{
				method:"get",
				url:"/order"       
			},
			insert:{
				method:"post",
				url:"/order"
			},
			update:{
				method:"put",
				url:"/order"
			},
			remove:{
				method:"delete",
				url:"/order/${id}"
			}
		},
		search:{
			form:{},
			options:[
				{
					key:"bid",
					type:"el-input",
					label:"账单编号",
					required:false,
					props:{
						clearable:true,
						filterable:true
					}
    
				},
				{
					key:"orderNo",
					type:"el-input",
					label:"订单号",
					required:false,
					props:{
						clearable:true
					}
    
				},
				{
					key:"orderId",
					type:"el-input",
					label:"订单id",
					required:false,
					props:{
						clearable:true
					}
    
				},
				{
					key:"test",
					type:"el-button",
					label:"查询",
					removeLabel:true,
					width:false,
					props:{
						type:"primary",
						// size:"medium"
					},
					listeners:{
						click(...e){
							that.searchFun && that.searchFun instanceof Function && that.searchFun(...e)
							that.$emit("search")
							console.log("click")
							that.getList()
						}
					}
				},
			],
			direction:"h",
			labelPosition:"right"
		},
		operation:{
			form:{},
			direction:"h",
			options:[
				{
					key:"btn1",
					type:"el-button",
					label:"添加",
					width:false,
					removeLabel:true,
					props:{
						type:"primary",
						// size:"medium",
						icon:"el-icon-plus"
					},
					listeners:{
						click:(...e)=>{
							console.log(that)
							that.addFun && that.addFun instanceof Function && that.addFun(...e)
						}
					}
				},
				{
					key:"batchChange",
					type:"el-button",
					label:"批量修改订单状态",
					slot:"batchChange",
					width:false,
					removeLabel:true,
					props:{
						type:"danger",
						size:"mini",
					},
				}
			]
		},
		updateField:async (form={orderCreateTime:getDateDetail()})=>{
			return {
				form,
				direction:"h",
				options:[
					{
						key:"bid",
						label:"账单编号",
						// type:"el-select",
						type:"el-select-v2",
						readStore:"billOption",
						required:true,
						props:{
							filterable:true,
							options:store.state.option.billOption
						}
					},
					{
						key:"orderId",
						label:"订单id",
						type:"el-input",
						required:true
					},
					{
						key:"orderNo",
						label:"订单号",
						type:"el-input",
						required:true
					},
					{
						key:"money",
						label:"每单结算金额",
						type:"el-input",
						required:true,
						props:{
							type:"number"
						}
					},
					{
						key:"amount",
						label:"实付金额",
						type:"el-input",
						required:true,
						props:{
							type:"number"
						}
					},
					{
						key:"nickname",
						label:"微信昵称",
						type:"el-input",
						// required:true
					},
					{
						key:"phone",
						label:"手机尾号",
						type:"el-input",
						// required:true
					},
					{
						key:"orderCreateTime",
						label:"订单创建时间",
						type:"el-date-picker",
						required:true,
						props:{
							type:"datetime",
							format:"yyyy-MM-dd HH:mm:ss",
							"value-format":"yyyy-MM-dd HH:mm:ss"
						},
					},
					{
						key:"imgList",
						label:"订单截图",
						type:fileUpload,
						width:"500px",
						props:{
							actionType:"images/order",
							imageField:"imgList",
							multiple:true
							
						},
						required:true,
					}
                    
				]
			}
		},
		config:{
			table:{
				checkbox:true,
				 
			},
			dialog:{
				top:"3vh"
			},
			
		}
        
	}
}